<script lang="ts" setup>
defineProps<{
  active: boolean
}>()

defineEmits<{
  (e: 'click'): void
}>()
</script>

<template>
  <button
    type="button"
    class="pr-NavBarHamburger"
    :class="{ active }"
    aria-label="mobile navigation"
    :aria-expanded="active"
    aria-controls="pr-NavScreen"
    @click="$emit('click')"
  >
    <span class="container">
      <span class="top" />
      <span class="middle" />
      <span class="bottom" />
    </span>
  </button>
</template>

<style scoped>
/* stylelint-disable selector-class-pattern */
/* stylelint-disable declaration-block-single-line-max-declarations */
.pr-NavBarHamburger {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: var(--pr-nav-height);
}

@media (width >= 768px) {
  .pr-NavBarHamburger {
    display: none;
  }
}

.container {
  position: relative;
  width: 16px;
  height: 14px;
  overflow: hidden;
}

.pr-NavBarHamburger:hover .top    { top: 0; left: 0; transform: translateX(4px); }
.pr-NavBarHamburger:hover .middle { top: 6px; left: 0; transform: translateX(0); }
.pr-NavBarHamburger:hover .bottom { top: 12px; left: 0; transform: translateX(8px); }

.pr-NavBarHamburger.active .top    { top: 6px; transform: translateX(0) rotate(225deg); }
.pr-NavBarHamburger.active .middle { top: 6px; transform: translateX(16px); }
.pr-NavBarHamburger.active .bottom { top: 6px; transform: translateX(0) rotate(135deg); }

.pr-NavBarHamburger.active:hover .top,
.pr-NavBarHamburger.active:hover .middle,
.pr-NavBarHamburger.active:hover .bottom {
  background-color: var(--pr-c-text-2);
  transition: top .25s, background-color .25s, transform .25s;
}

.top,
.middle,
.bottom {
  position: absolute;
  width: 16px;
  height: 2px;
  background-color: var(--pr-c-text-1);
  transition: top .25s, background-color .5s, transform .25s;
}

.top    { top: 0; left: 0; transform: translateX(0); }
.middle { top: 6px; left: 0; transform: translateX(8px); }
.bottom { top: 12px; left: 0; transform: translateX(4px); }
</style>
